def non_repeat_substring(str1):
  start = 0
  out_dict = {}
  max_length = 0
  for end in range(len(str1)):
    right_key = str1[end]
    if right_key not in out_dict:
      out_dict[right_key] = 0
    out_dict[right_key] += 1
    if(out_dict[right_key]>1):
      left_key = str1[start]
      out_dict[left_key] -= 1
      start += 1 
      if(out_dict[left_key] == 0):
        del out_dict[left_key]
      max_length = max(max_length,end-start+1)

  # TODO: Write your code here
  return max_length


def main():
  print("Length of the longest substring: " + str(non_repeat_substring("aabccbb")))
  print("Length of the longest substring: " + str(non_repeat_substring("abbbb")))
  print("Length of the longest substring: " + str(non_repeat_substring("abccde")))


main()